import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'vue-router'
import router from './router'
import './plugins/element-ui.js'
import 'normalize.css'
// 阿里巴巴矢量图
import './assets/css/iconfont.css'
import mixin from './utils/dialogVisibleMixin'
import store from './store'
const originalReplace = VueRouter.prototype.replace


// 使用树形列表插件
import TreeTable from 'vue-table-with-tree-grid'
Vue.component('tree-table', TreeTable)


VueRouter.prototype.replace = function replace(location) {
  return originalReplace.call(this, location).catch(err => err)
}

Vue.use(VueRouter)
Vue.config.productionTip = false

Vue.filter('datetime', function (timestamp) {
  if (!timestamp) return ''
  let a = new Date(timestamp).getTime()
  const date = new Date(a)
  const Y = date.getFullYear() + '-'
  const M =
    (date.getMonth() + 1 < 10
      ? '0' + (date.getMonth() + 1)
      : date.getMonth() + 1) + '-'
  const D =
    (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + '  '
  const h =
    (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
  const m =
    (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes())+':'
  const s = date.getSeconds(); // 秒
  const dateString = Y + M + D + h + m +s
  return dateString
})

Vue.mixin(mixin)

new Vue({
  render: h => h(App),
  router,
  store
}).$mount('#app')
